﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Commonlib;
using Albon.Model;
namespace DAL
{
    public class ItemStyleDAL
    {
        public bool addItemStyle(ItemStyle itemstyle)
        {
            SqlParameter[] parameters = new SqlParameter[] { 
                new  SqlParameter("@orderitemid",itemstyle.orderItemID),
                new SqlParameter("@keyid",itemstyle.keyID),
                new SqlParameter("@valueid",itemstyle.valueID),
                new SqlParameter("@value",itemstyle.Value)
            };
           int ret= SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.StoredProcedure, "p_itemstyleadd", parameters);
           return ret > 0;  
        }

        public DataTable getItemStyle(string orderitemid)
        {
            string cmdstr = "select * from ItemStyle where orderItemID="+orderitemid;
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }

        //添加备注信息（包括样式图片）
        public void addRemark(StyleRemark styleremark)
        {
            SqlParameter[] parameters = new SqlParameter[] {
					new SqlParameter("@styleID", styleremark.styleID),
					new SqlParameter("@orderItemID", styleremark.orderItemID),
					new SqlParameter("@remark", styleremark.remark),
					new SqlParameter("@imgPath",styleremark.imgPath)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.StoredProcedure, "p_itemstyleremark", parameters);
        }

        //获取备注和样式图片信息
        public DataTable getStyleRemark(string orderitemid, string styleid)
        {
            string cmdstr = "select * from StyleRemark where orderItemID="+orderitemid+" and styleID="+styleid;
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }
    }
}
